import Vue from "vue";
import App from "./App.vue";
import "@babel/polyfill"; // 配置ie兼容
import router from "@/router";
import store from "@/store";
import pubsub from "pubsub-js"; // js 消息
import envConfig from "@/config/envConfig"; // 环境参数配置
import moment from "moment"; // moment 时间操作工具
import * as filters from "@/config/filtersConfig"; // 过滤器
import request from "@/utils/request"; // 请求工具类
import common from "@/utils/common"; // 常用工具
import "./assets/fonts/icon.css"; // 自定义 svg转font字体样式
// element-ui
import "@/plugins/element/element.js";
import "@/assets/scss/public.scss";
import message from "./utils/message";
import MainHead from "./components/models/MainHead";
import MainContent from "./components/models/MainContent";
import "default-passive-events";
import ECharts from 'echarts'

Vue.prototype.$echarts = ECharts

if (process.env.NODE_ENV == "development") {
  Vue.config.devtools = true;
} else {
  Vue.config.devtools = false;
}

import qs from "qs";
import { getPermissions, hasPermission, hasRole } from "@/utils/auth";
import download from "@/plugins/download";
import { isNull } from "@/utils/service";

Vue.prototype.$qs = qs;

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

// 主题换肤
// initThemeColor();

Vue.component("main-head", MainHead);
Vue.component("main-content", MainContent);
// Vue.use(ElementUI)
Vue.prototype.$envConfig = envConfig;
Vue.prototype.$moment = moment;
Vue.prototype.$request = request;
Vue.prototype.$common = common;
Vue.prototype.$pubsub = pubsub;
Vue.prototype.$message = message;
Vue.prototype.$download = download;
Vue.config.productionTip = false;
//挂载全局方法
Vue.prototype.isNull = isNull;

import { UTable, UTableColumn } from "umy-ui";
import "umy-ui/lib/theme-chalk/index.css";// 引入样式

Vue.use(UTable);
Vue.use(UTableColumn);

import VueClipboard from "vue-clipboard2";

Vue.use(VueClipboard);


// 按扭权限指令
Vue.directive("permission", {
  inserted(el, binding) {
    // console.log("当前校验权限 : ", binding.value)
    if (!hasPermission(binding.value)) {
      el.remove();
    }
  }
});
// 按钮角色权限
Vue.directive("role", {
  inserted(el, binding) {
    if (!hasRole(binding.value)) {
      el.remove();
    }
  }
});
window.addEventListener("popstate", function(e) {
  router.isBack = true;
});


new Vue({
  el: "#app",
  router,
  store,
  render: h => h(App)
});
